Skip to content

Utilize new wait extension methods #8619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 18, 2025

Conversation

parlough
Copy link
Member

@parlough parlough commented Dec 10, 2024

These are a bit cleaner in general, but especially so when you need to wait for and access futures with different types.

@parlough parlough marked this pull request as ready for review February 17, 2025 22:19
argumentsDescriptorFuture,
entriesFuture,
]).then((result) => populateLists(result[0], result[1]));
).wait.then((result) => populateLists(result.$1, result.$2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, so .wait works on a record too, not just lists? Is there a way to name the record results so that we don't have to use $1 and $2 ?

Copy link
Member Author

@parlough parlough Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So .wait works on a record too, not just lists?

Yep, and that's when it shines as it allows you to access specific items with their respective types :D

Is there a way to name the record results so that we don't have to use $1 and $2 ?

The .wait extension only exists for records with just positional fields, but you can destructure them using a pattern. In this case, since the function wasn't using async/await, it took a bit more restructuring. I went ahead and did that in 04334cd

@parlough parlough merged commit 5d3649d into flutter:master Feb 18, 2025
41 checks passed
@parlough parlough deleted the feat/wait-extension-methods branch February 18, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants